package net.aiion.weave.spi.painters.stream.identicons;

import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;

/**
 * This interface specifies basic operations of an <tt>Identicon</tt> implementation. An <tt>Identicon</tt> is basically
 * a visual representation of a hash value, such as MD5 or SHA-1.
 * 
 * @author Stefan Braune
 */
public interface Identicon
{
    /**
     * Sets the horizontal and vertical size for the <tt>Identicon</tt> in pixels. An <tt>Identicon</tt> implementation
     * may define a minimum size to render a image which can be recognized appropriately at small resolutions.
     * 
     * @param identiconSize
     */
    void setSize(int identiconSize);

    int getSize();

    void setBackgroundColor(Color backgroundColor);

    Color getBackgroundColor();

    /**
     * Sets a {@link Color} used for rendering the shapes in the <tt>Identicon</tt>. If no {@link Color} is set, it will
     * be calculated based on the provided data.
     * 
     * @param foregroundColor
     * @see #setData(byte[])
     * @see #setData(String)
     */
    void setForegroundColor(Color foregroundColor);

    Color getForegroundColor();

    void enableRotation();

    void disableRotation();

    boolean rotationActive();

    void setData(String identiconData);

    void setData(byte[] identiconData);

    void drawIdenticon(OutputStream outputStream) throws IOException;
}
